package com.example.demo.alarm.service.impl;

import com.example.demo.alarm.dao.AlarmList;
import com.example.demo.alarm.mapper.AlarmListMapper;
import com.example.demo.alarm.service.AlarmListService;
import com.example.demo.system.utility.PageInfo;
import com.example.demo.system.utility.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AlarmListServiceImpl implements AlarmListService {

    @Autowired
    private AlarmListMapper alarmListMapper;

    @Override
    public Result getList(Integer pageNum, Integer pageSize, String name, String startTime, String endTime) {
        Integer start = PageInfo.start(pageNum, pageSize);
        List<AlarmList> list = alarmListMapper.getList(start, pageSize, name, startTime, endTime);
        Integer listCount = alarmListMapper.getListCount(name, startTime, endTime);
        PageInfo info = new PageInfo(pageNum, pageSize, listCount, list);
        return Result.success(info);
    }

    @Override
    public Result get(Integer id) {
        return Result.success(alarmListMapper.get(id));
    }

    //综合看板
    @Override
    public Result integratedSignage(String spaceName) {
        return Result.success(alarmListMapper.integratedSignage(spaceName));
    }

    //综合看板，健康值和舒适度
    @Override
    public Result getHealthOrComfort(String spaceName){
        AlarmListUtil alarm = new AlarmListUtil();
        String health = alarm.getHealthOrComfort("health", spaceName);
        String comfort = alarm.getHealthOrComfort("comfort", spaceName);
        Map<String, String> map = new HashMap<>();
        map.put("health",health);
        map.put("comfort",comfort);
        return Result.success(map);

    }

}
